import { store } from "@/store";
import { defineStore } from "pinia";
import { customRect } from "@/assets/script/stencilComponentManager"
import { Graph } from "@antv/x6";
import { Stencil } from "@antv/x6-plugin-stencil";
interface StencilState {
    stencilComponents: any;
}

/**
 * @description 
 */
const useStencilStore = defineStore({
    id: 'stencil',
    state: (): StencilState => ({
        stencilComponents: []
    }),
    getters: {

    },
    actions: {
        initStencilComponent(stencli: Stencil, graph: Graph) {
            let nodeCreate = []
            customRect.forEach(v => {
                nodeCreate.push(graph.createNode(v))
            })
            stencli.load(nodeCreate, 'group1')
        }
    }
});

export function useStencilStoreHook() {
    return useStencilStore(store);
}
